<!DOCTYPE html>
<html>

	<head>
		<title>修改</title>
		<meta charset="utf-8">
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="css/news.css">
	</head>

	<body>
		<div id="top">
			<img class="goback1" src="img/back.png" style="position: absolute;width: 42px;left: 2%;top: 10%;" />
			<label>Google News</label>
		</div>
		<div id="center">
			<img id="regtouxiang" src="">

			<div id="reg_text">
				<input id="usernamae" type="text" name="" disabled="true"><br>
				<input style="width: 80%;height: 50px;margin-top: 20px;
	        margin-left: 10%;border:0px;border-radius: 5px;" id="password" type="password" name="" placeholder="请输入新密码"><br>
				<input id="shuoshuo" type="text" name="" placeholder="个性签名"><br>
				<input id="email" type="text" name="" placeholder="请输入邮箱"><br>
			</div>

		</div>
		<div id="foot">
			<input id="regbtn" type="button" name="" value="提交修改">
		</div>
		<script src="js/jquery-3.2.1.js"></script>
		<script type="text/javascript">
			$(function() {
				$.ajax({
					type: "post",
					url: "http://127.0.0.1/news/update.php",
					async: true,
					dataType: "json",
					success: function(xhr) {
						$('#usernamae').attr('value',xhr[0].name);
						$('#regtouxiang').attr('src',xhr[0].touxiang_img);
						$('#password').attr('value',xhr[0].password);
						$('#shuoshuo').attr('value',xhr[0].string);
						$('#email').attr('value',xhr[0].email);
					}
				});
				
				$("#regbtn").on("click",function(){
					$.ajax({
						type:"post",
						url:"http://127.0.0.1/news/xiugai.php",
						async:true,
						dataType:"json",
						data:{
							pass:$("#password").val(),
							shuoshuo:$("#shuoshuo").val(),
							email:$("#email").val()
						},
						success:function(data){
						if(data['code']==1){
							window.location.href="index.html";
						}else if(data['code']==-1){
							alert("电子邮箱格式不正确");
						}else if(data['code']==-10012){
							alert("密码为空");
						}
						}
						
					});
				})
				$(".goback1").on("click",function(){
					window.history.back(-1);
				});
			})
		</script>
	</body>

</html>